<template>
	<view :class="[primarySize()]">
		<view class="nav m-list-flex">
			<view class="m-cell-bd tc" :class="[query.status==0?'active':'']" @click="bindStatusChange(0)">
				<text>已邀请</text><text class="mark" v-if="tabNumber.tab_0>0">{{tabNumber.tab_0}}</text>
			</view>
			<view class="m-cell-bd tc" :class="[query.status==2?'active':'']" @click="bindStatusChange(2)">
				<text>已同意</text><text class="mark" v-if="tabNumber.tab_2>0">{{tabNumber.tab_2}}</text>
			</view>
			<view class="m-cell-bd tc" :class="[query.status==1?'active':'']" @click="bindStatusChange(1)">
				<text>已拒绝</text>
			</view>
		</view>
		<view class="page-foot">
			<Footer :identity="2" :footState="3" :num="megNum"></Footer>
		</view>
		<view class="container">
			<view class="plr30 ptb15">
				<view>
					<block v-for="(interview,index) in interviews">
						<navigator :url="'/pages/user/post_info?id='+ interview.job_id" class="business_item">
							<view class="recom_info">
								<view class="m-list-flex">
									<view class="business_img">
										<image src="https://admin.mosizp.cn/static/public/business_logo.png"></image>
									</view>
									<view class="m-cell-bd business_info">
										<view class="m-list-flex">
											<view class="fs32 col0 fd m-cell-bd m-ellipsis">
												{{interview.resume.personal.realname}}
											</view>
											<view class="fs24 col9">
												{{formatDatetime(interview.createtime,'mm月dd日')}}
											</view>
										</view>

										<view class="m-list-flex">
											<view class="m-cell-bd mr50">
												<view class="fs24 col3 pt20">面试岗位：<text
														class="col0">{{interview.job.job_name}}</text></view>
												<!-- <view class="fs24 col3 pt10">期望薪资：<text class="recom_price">{{interview.resume.job_intention.expect_salary.name}}／月</text></view> -->
												<view class="pt24 pt10 clearfix">
													<view class="star_type">{{interview.resume.personal.age}}岁</view>
													<view class="star_type">
														{{interview.resume.personal.work_experience.name}}
													</view>
													<view class="star_type">
														{{interview.resume.personal.education_level.name}}
													</view>
												</view>
											</view>
											<image :src="iconPath('status_img0.png')" mode='widthFix' class='status_img' v-if='interview.status==0'></image>
											<image :src="'https://admin.mosizp.cn/static/public/status_img9.png'" mode='widthFix' class='status_img' v-else-if="interview.status==1"></image>
											<image :src="iconPath('status_img8.png')" mode='widthFix' class='status_img' v-else></image>
										</view>
									</view>
								</view>

							</view>
							<view class="recom_btn m-list-flex" v-if='interview.status==2'>
								<button hover-class="none" @click.stop="bindFailInterview(index)"
									class="m-cell-bd">面试不合格</button>
								<button hover-class="none" @click.stop="bindPassInterview(index)"
									class="m-cell-bd invite">面试录取</button>
							</view>
							<view class="recom_btn m-list-flex" v-else-if='interview.status==3'>
								<button hover-class="none" class="m-cell-bd">面试不合格</button>
							</view>
							<view class="recom_btn m-list-flex" v-else-if='interview.status==4'>
								<button hover-class="none" class="m-cell-bd invite">面试已录取</button>
							</view>
						</navigator>
					</block>
				</view>
				<view class="nothing" v-if="interviewsMore.nothing">
					<image class="img_nothing" src="https://admin.mosizp.cn/static/public/icon_nothing.png" mode="aspectFill"></image>
					<text>抱歉，暂无相关信息</text>
				</view>
				<button @click="fetch" v-else hover-class="none" class="more_btn mt30">{{interviewsMore.text}}</button>
			</view>

		</view>
	</view>
</template>

<script>
	const app = getApp()
	export default {
		data() {
			return {
				tabNumber: {
					tab_0: 0,
					tab_1: 0,
					tab_2: 0,
					tab_3: 0,
					tab_4: 0
				},
				query: {
					status: 0
				},
				interviews: [],
				interviewsMore: {
					page: 1
				},
				userinfo: null,
				megNum: 0,
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onReachBottom() {
			this.fetch();
		},
		onLoad() {
			this.tabNumberChoose();
			this.fetch();
			if (this.$core.getUserinfo()) {
				this.userinfo = this.$core.getUserinfo()
			}
			uni.$on(app.globalData.Events.UserLogin, this.eventOnUserLogin, this);
			uni.$on(app.globalData.Events.UserLogout, this.eventOnUserLogout, this);
			if (app.globalData.chat_config.SocketTask) {
				this.$chatIM.setMessageBadge(false)
			}
			uni.$on(app.globalData.Events.WebsocketMessageCount, this.eventWebsocketMessageCount, this);
			
		},
		onUnload() {
			uni.$off(app.globalData.Events.UserLogin, this.eventOnUserLogin, this);
			uni.$off(app.globalData.Events.UserLogout, this.eventOnUserLogout, this);
			uni.$off(app.globalData.Events.WebsocketMessageCount, this.eventWebsocketMessageCount);
		},
		onPullDownRefresh(){
			this.refresh()
		},
		methods: {
			bindStatusChange(status) {
				this.query.status = status
				this.refresh();
			},
			refresh: function() {
				this.interviews = []
				this.interviewsMore = {
					page: 1
				}
				this.tabNumberChoose();
				this.fetch();
				uni.stopPullDownRefresh();
			},
			fetch() {
				this.$util.fetch(this, '/xilujob.job_interview/company_list', this.query, 'interviewsMore', 'interviews',
					'data');
			},

			bindFailInterview(index) {
				let interview = this.interviews[index];
				uni.showModal({
					title: '提示',
					content: '确认面试不合格？',
					success: res => {
						if (res.confirm) {
							this.$core.post({
								url: 'xilujob.job_interview/multi_status/interview_id/' + interview.id,
								data: {
									status: 3
								},
								success: ret => {
									this.$set(this.interviews[index], 'status', ret.data.status)
								}
							});
						}
					}
				})
			},
			bindPassInterview(index) {
				let interview = this.interviews[index];
				uni.showModal({
					title: '提示',
					content: '确认面试录取？',
					success: res => {
						if (res.confirm) {
							this.$core.post({
								url: 'xilujob.job_interview/multi_status/interview_id/' + interview.id,
								data: {
									status: 4
								},
								success: ret => {
									this.$set(this.interviews[index], 'status', ret.data.status)
								}
							});
						}
					}
				})
			},

			tabNumberChoose() {
				var page = this;
				this.$core.get({
					url: '/xilujob.job_interview/company_list_count',
					success(ret, response) {
						page.tabNumber=ret.data
					}
				});
			},
			eventOnUserLogin(userinfo) {
				this.userinfo = userinfo;
				if (this.userinfo.group_id == 2) {
					this.refresh();
				}
			},
			eventOnUserLogout() {
				this.userinfo = null;
			},
	eventWebsocketMessageCount(data) {
		this.megNum = this.userinfo ? app.globalData.chat_config.messageCount : 0;
		// this.$forceUpdate()
	},
		}
	}
</script>

<style scoped>
	.nav {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		background-color: #fff;
		line-height: 92rpx;
		justify-content: space-between;
		z-index: 20
	}

	.nav view {
		padding: 0 30rpx;
		position: relative;
	}

	.nav text {
		display: inline-block;
		position: relative;
		font-size: 28rpx;
	}

	.nav .active text::after {
		content: '';
		position: absolute;
		left: 0;
		right: 0;
		display: block;
		background-color: var(--primary);
		height: 4rpx;
		border-radius: 2rpx;
		bottom: 13rpx;
	}

	.nav .mark {
		position: absolute;
		right: 45rpx;
		top: 12rpx;
		font-size: 22rpx;
		color: #FFF;
		min-width: 35rpx;
		padding: 0 5rpx;
		height: 35rpx;
		background-color: var(--primary);
		line-height: 35rpx;
		text-align: center;
		border-radius: 50%;
	}

	.nav .mark::after {
		display: none !important;
	}

	.nav~.container {
		padding-top: 92rpx;
	}

	.recom_item {
		box-shadow: 0px 1px 18px 0px rgba(0, 0, 0, 0.06);
		background-color: #fff;
		border-radius: 4rpx;
		border: 1rpx solid #EBEBEB;
		margin-bottom: 18rpx;
		padding-top: 35rpx;
		position: relative;
		overflow: hidden
	}

	.recom_text .top {
		position: absolute;
		top: 0;
		right: 0;
		width: 74rpx;
		height: 74rpx;
	}

	.recom_item:nth-last-child(1) {
		margin-bottom: 0;
	}

	.recom_tit {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
		display: inline-block;
		vertical-align: middle
	}

	.recom_price {
		font-size: 28rpx;
		color: #f21b23;
		font-weight: bold;
		padding-top: 20rpx;
	}

	.recom_type {
		padding-top: 20rpx;
	}

	.recom_type_item {
		font-size: 20rpx;
		color: #999;
		background-color: #F7F7F7;
		float: left;
		line-height: 39rpx;
		padding: 0 15rpx;
		border-radius: 8rpx;
		margin-right: 17rpx;
		margin-bottom: 17rpx;
	}

	/* .recom_info{padding: 0 30rpx 15rpx;} */
	.clearfix {
		display: block;
	}

	.clearfix:after {
		content: "$";
		display: block;
		height: 0;
		clear: both;
		visibility: hidden;
		overflow: hidden;
	}

	.single-line {
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.multi-line {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.recom_business {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 30rpx;
		border-top: 1rpx solid #F6F6F6
	}

	.recom_business image {
		width: 24rpx;
		height: 24rpx;
		margin-right: 7rpx;
		display: block;
	}

	.recom_business .col0 {
		color: #000;
		flex: 1;
		overflow: hidden
	}

	.recom_business .col9 {
		color: #999
	}

	.recom_text image {
		width: 32rpx;
		height: 32rpx;
		display: inline-block;
		vertical-align: middle;
		margin-left: 12rpx;
	}

	.order_info {
		text-align: center;
		line-height: 36rpx;
		background-image: var(--primary);
		font-size: 22rpx;
		border-radius: 8rpx;
		overflow: hidden
	}

	.colff7 {
		color: var(--primary)
	}

	.colf {
		color: #fff
	}

	.bgf {
		background-color: #fff;
		border-radius: 0 0 8rpx 8rpx
	}

	.order_info>view {
		width: 121rpx;
	}

	.p1 {
		padding: 1rpx;
		box-sizing: border-box
	}

	/* 组件 - flex */
	.m-list-flex {
		display: flex;
		align-items: center;
	}

	.m-list-flex .m-cell-bd {
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		overflow: hidden;
	}

	.fs24 {
		font-size: 24rpx;
	}

	.col9 {
		color: #999
	}





	.recom_item {
		box-shadow: 0px 1px 18px 0px rgba(0, 0, 0, 0.06);
		background-color: #fff;
		border-radius: 4rpx;
		border: 1rpx solid #EBEBEB;
		margin-bottom: 18rpx;
		padding-top: 35rpx;
		position: relative;
		overflow: hidden
	}

	.recom_text .top {
		position: absolute;
		top: 0;
		right: 0;
		width: 74rpx;
		height: 74rpx;
	}

	.recom_item:nth-last-child(1) {
		margin-bottom: 0;
	}

	.recom_tit {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
		display: inline-block;
		vertical-align: middle
	}

	.recom_price {
		font-size: 28rpx;
		color: #f21b23;
		font-weight: bold;
		padding-top: 20rpx;
	}

	.recom_type {
		padding-top: 20rpx;
	}

	.recom_type_item {
		font-size: 20rpx;
		color: #999;
		background-color: #F7F7F7;
		float: left;
		line-height: 39rpx;
		padding: 0 15rpx;
		border-radius: 8rpx;
		margin-right: 17rpx;
		margin-bottom: 17rpx;
	}

	/* .recom_info{padding: 0 30rpx 15rpx;} */
	.clearfix {
		display: block;
	}

	.clearfix:after {
		content: "$";
		display: block;
		height: 0;
		clear: both;
		visibility: hidden;
		overflow: hidden;
	}

	.single-line {
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}

	.multi-line {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.recom_business {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 30rpx;
		border-top: 1rpx solid #F6F6F6
	}

	.recom_business image {
		width: 24rpx;
		height: 24rpx;
		margin-right: 7rpx;
		display: block;
	}

	.recom_business .col0 {
		color: #000;
		flex: 1;
		overflow: hidden
	}

	.recom_business .col9 {
		color: #999
	}

	.recom_text image {
		width: 32rpx;
		height: 32rpx;
		display: inline-block;
		vertical-align: middle;
		margin-left: 12rpx;
	}

	.order_info {
		text-align: center;
		line-height: 36rpx;
		background-color: var(--primary);
		font-size: 22rpx;
		border-radius: 8rpx;
		overflow: hidden
	}

	.colff7 {
		color: var(--primary)
	}

	.colf {
		color: #fff
	}

	.bgf {
		background-color: #fff;
		border-radius: 0 0 8rpx 8rpx
	}

	.order_info>view {
		width: 121rpx;
	}

	.p1 {
		padding: 1rpx;
		box-sizing: border-box
	}

	/* 组件 - flex */
	.m-list-flex {
		display: flex;
		align-items: center;
	}

	.m-list-flex .m-cell-bd {
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		overflow: hidden;
	}

	.fs24 {
		font-size: 24rpx;
	}

	.col9 {
		color: #999
	}

	.pt20 {
		padding-top: 20rpx;
	}

	.pt5 {
		padding-top: 5rpx;
	}

	.recom_btn {
		border-top: 1rpx solid #F6F6F6
	}

	.recom_btn button {
		line-height: 88rpx;
		height: 88rpx;
		color: #999999;
		font-size: 24rpx;
	}

	.recom_btn .invite {
		color: var(--primary);
		position: relative
	}

	.recom_btn .invite::after {
		content: '';
		position: absolute;
		left: 0;
		top: 50%;
		transform: translateY(-50%);
		width: 1rpx;
		height: 22rpx;
		background-color: #F3F3F3;
		display: block
	}

	.status_img {
		width: 107rpx;
		height: 81rpx;
		display: block
	}




	.header_img {
		width: 58rpx;
		height: 58rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 24rpx;
	}

	.header_img image {
		width: 100%;
		height: 100%;
		display: block
	}

	.phone_img {
		width: 40rpx;
		height: 40rpx;
		display: block
	}


	.business_item {
		box-shadow: 0px 1px 18px 0px rgba(0, 0, 0, 0.06);
		background-color: #fff;
		border-radius: 4rpx;
		border: 1rpx solid #EBEBEB;
		margin-bottom: 18rpx;
		padding: 35rpx 30rpx 10rpx;
		position: relative;
		overflow: hidden;
	}

	.business_img {
		align-self: flex-start;
		margin-top: 20rpx;
	}

	.business_img image {
		width: 81rpx;
		height: 81rpx;
		margin: 0 20rpx 0 0;
		display: block
	}

	/* .business_img image{width: 100%;height: 100%;display: block} */
	.business_info {
		font-size: 24rpx;
		color: #333
	}

	.cancel_star {
		font-size: 20rpx;
		color: #999;
		line-height: 39rpx;
		height: 39rpx;
		border-radius: 8rpx;
		border: 1rpx solid #E1E1E1;
		padding: 0 15rpx;
		margin-bottom: 13rpx;
		margin: 24rpx 26rpx 0 0;
		width: 107rpx;
		text-align: center
	}

	.star_type {
		float: left;
		font-size: 20rpx;
		color: #999;
		border-radius: 8rpx;
		line-height: 39rpx;
		height: 39rpx;
		padding: 0 17rpx;
		background-color: #F7F7F7;
		border: 1rpx solid #F7F7F7;
		margin-right: 13rpx;
		margin-bottom: 13rpx;
	}

	.mr50 {
		margin-right: 50rpx;
	}
</style>